package com.gitee.wsl.platform.thread.task.api

import com.gitee.wsl.platform.concurrent.api.Cancellable
import com.gitee.wsl.platform.thread.task.callback.CompletionCallback
import org.jetbrains.annotations.NonBlocking
import java.io.Serializable
import java.util.concurrent.Executor

/**
 * A function that is a delayed, asynchronous computation.
 *
 *
 * This function type is what's needed to describe [Task] instances.
 */
@FunctionalInterface
@NonBlocking
fun interface AsyncFun<T> : Serializable {
    fun invoke(
        executor: Executor,
        continuation: CompletionCallback<in T>,
    ): Cancellable
}
